package edu.neu.swc.commerce.blockHandler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import edu.neu.swc.commerce.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * <h1>自定义限流处理逻辑</h1>
 */
@Slf4j
public class QinyiBlockHandler {

    /**
     * <h2>通用限流处理方法，必须是静态</h2>
     */
    public static CommonResponse<String> qinyiHandleBlockException(
            BlockException exception){
        log.error("trigger qinyi block handler:[{}],[{}]",
                JSON.toJSONString(exception.getRule()),exception.getRuleLimitApp());
        return new CommonResponse<>(
                -1,
                "flow rule trigger block exception",
                null
        );
    }
}
